package com.offcn.controller;

import java.util.List;


import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import com.offcn.entity.Product;
import com.offcn.entity.ProductCategory;
import com.offcn.entity.ProductCategoryVo;
import com.offcn.service.IProductCategoryService;
import com.offcn.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ProductCategoryController {

	@Resource
	private IProductCategoryService productCategoryService;
	@Resource
	private ProductService productService;

	
	//首页显示一二三级目录的方法
	@RequestMapping("/threeProduct")
	public String threeProduct(Model model,HttpSession session) {
		List<ProductCategory> firstProductCategoryList = productCategoryService.findFirstProductCategory();
		List<ProductCategoryVo> productCategoryVoList = productCategoryService.findProductCategory();
		List<Product> productList = productService.findAllProduct();
           session.setAttribute("productCategoryVoList",productCategoryVoList);
	      session.setAttribute("firstProductCategoryList", firstProductCategoryList);
	     session.setAttribute("productList",productList);

		return "mall";
	}



    @RequestMapping("/toQueryProductList3/{id}")
    public String toQueryProductList3(@PathVariable int id, HttpSession session) {
        //我不需要查询，我只需要把这个二级idset到session就行了，待会用ajax再查一遍的	，把之前一级存的session的id干掉
        session.removeAttribute("firstId");
        session.removeAttribute("secondId");
        session.setAttribute("thirdId", id);
        return "productDeal.jsp";
    }
	

	

	
}
